package com.ruoyi.rsikManage.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rsikManage.domain.TAlarmThresholdConfig;
import com.ruoyi.rsikManage.service.ITAlarmThresholdConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警阈值配置Controller
 *
 * @author wu
 * @date 2023-08-29
 */
@RestController
@RequestMapping("/zdzh/tAlarmThresholdConfig")
public class TAlarmThresholdConfigController extends BaseController {
    @Autowired
    private ITAlarmThresholdConfigService tAlarmThresholdConfigService;

    /**
     * 查询报警阈值配置列表
     */
    @PreAuthorize("@ss.hasPermi('zdzh:tAlarmThresholdConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAlarmThresholdConfig tAlarmThresholdConfig) {
        startPage();
        List<TAlarmThresholdConfig> list = tAlarmThresholdConfigService.selectTAlarmThresholdConfigList(tAlarmThresholdConfig);
        return getDataTable(list);
    }

    /**
     * 导出报警阈值配置列表
     */
    @PreAuthorize("@ss.hasPermi('zdzh:tAlarmThresholdConfig:export')")
    @Log(title = "报警阈值配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TAlarmThresholdConfig tAlarmThresholdConfig) {
        List<TAlarmThresholdConfig> list = tAlarmThresholdConfigService.selectTAlarmThresholdConfigList(tAlarmThresholdConfig);
        ExcelUtil<TAlarmThresholdConfig> util = new ExcelUtil<TAlarmThresholdConfig>(TAlarmThresholdConfig.class);
        return util.exportExcel(list, "tAlarmThresholdConfig");
    }

    /**
     * 获取报警阈值配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('zdzh:tAlarmThresholdConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tAlarmThresholdConfigService.selectTAlarmThresholdConfigById(id));
    }

    /**
     * 新增报警阈值配置
     */
    @PreAuthorize("@ss.hasPermi('zdzh:tAlarmThresholdConfig:add')")
    @Log(title = "报警阈值配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAlarmThresholdConfig tAlarmThresholdConfig) {
        return toAjax(tAlarmThresholdConfigService.insertTAlarmThresholdConfig(tAlarmThresholdConfig));
    }

    /**
     * 修改报警阈值配置
     */
    @PreAuthorize("@ss.hasPermi('zdzh:tAlarmThresholdConfig:edit')")
    @Log(title = "报警阈值配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAlarmThresholdConfig tAlarmThresholdConfig) {
        return toAjax(tAlarmThresholdConfigService.updateTAlarmThresholdConfig(tAlarmThresholdConfig));
    }

    /**
     * 删除报警阈值配置
     */
    @PreAuthorize("@ss.hasPermi('zdzh:tAlarmThresholdConfig:remove')")
    @Log(title = "报警阈值配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tAlarmThresholdConfigService.deleteTAlarmThresholdConfigByIds(ids));
    }
}
